Skip to content

Upgrade msw-storybook-addon to v3 and msw to 2.15.0 - #1230

Merged
dgee2 merged 2 commits into
deps-jsdom-majorfrom
deps-msw-storybook-addon-major
Aug 14, 2026
Merged

Upgrade msw-storybook-addon to v3 and msw to 2.15.0#1230
dgee2 merged 2 commits into
deps-jsdom-majorfrom
deps-msw-storybook-addon-major

Conversation

@dgee2

@dgee2 dgee2 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Bumps msw-storybook-addon 2.0.6 -> 3.0.0 and msw 2.12.14 -> 2.15.0
(these move together; msw-storybook-addon@2.0.6 is incompatible with
msw's newer worker internals, which is why Group 1 pinned msw down
via a pnpm override). Removes that override now that the addon
supports current msw.

msw-storybook-addon v3 removes initialize()/mswLoader in favor of
a definePreview-style addons: [addonMsw(setupFn)] call, and drops
parameters.msw support for CSF Next (this project's story format)
in favor of a beforeEach({ msw }) { msw.use(handler) } hook per
story. Updated .storybook/preview.ts and the three story files that
registered handlers accordingly.

This also surfaced and fixed two pre-existing, MSW-adjacent problems
that AGENTS.md had documented as "not currently reliable":

  • MSW genuinely wasn't intercepting requests under
    vitest --project=storybook before (confirmed by probing — a
    stricter assertion against a previously "passing" story failed
    until the beforeEach migration). It works correctly now; updated
    AGENTS.md's component-testing guidance to match and removed the
    workaround comments in the affected story files.
  • .storybook/msw-handlers.ts's recipe list fixtures used name
    instead of the real API's title field, which had gone unnoticed
    because MSW wasn't actually serving the response before.

Verified: lint, build, unit tests (57/57), storybook interaction
tests (78/78, now genuinely exercising mocked responses rather than
incidentally matching a fallback UI state), and a dev-server smoke
check. Playwright e2e (pnpm run test:e2e) fails, but on an
unrelated pre-existing stale scaffold assertion ("You did it!") that
doesn't match this app's actual content and is unmodified from main.

Co-authored-by: Claude noreply@anthropic.com


Stack created with GitHub Stacks CLIGive Feedback 💬

@dgee2
dgee2 force-pushed the deps-msw-storybook-addon-major branch from 7f9db45 to 3e67f50 Compare August 13, 2026 21:45
@dgee2
dgee2 marked this pull request as ready for review August 14, 2026 20:46
Copilot AI lite review requested due to automatic review settings August 14, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the frontend’s Storybook/MSW mocking stack by bumping msw-storybook-addon to v3 and msw to 2.15.0, updating Storybook preview/stories to the new v3 registration pattern so interaction tests reliably exercise mocked API responses.

Changes:

  • Upgrade msw and msw-storybook-addon, removing the prior pnpm override that pinned msw.
  • Migrate Storybook MSW setup from initialize()/mswLoader + parameters.msw to addonMsw(setupWorker) + per-story beforeEach({ msw }) { msw.use(...) }.
  • Fix Storybook MSW fixtures to match the app’s expected recipe list shape (title and numeric id), and update the generated mockServiceWorker.js to MSW 2.15.0.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ui/menu-website/tsconfig.storybook.json Adds MSW addon types for Storybook typechecking (currently drops Node types; see comment).
ui/menu-website/.storybook/preview.ts Switches to MSW v2 + addon v3 initialization via setupWorker and addonMsw, and registers global handlers via beforeEach.
ui/menu-website/.storybook/msw-handlers.ts Updates mocked recipe list fixtures to use title and numeric id.
ui/menu-website/src/pages/RecipeList.stories.ts Migrates MSW handler registration to per-story beforeEach and tightens assertions to validate mocked data is rendered.
ui/menu-website/src/pages/RecipeDetail.stories.ts Same per-story MSW migration and asserts on mocked recipe title.
ui/menu-website/src/components/organisms/recipe/new-recipe-form.stories.ts Migrates POST handlers to per-story beforeEach for submit success/failure stories.
ui/menu-website/.storybook/main.ts (Indirectly impacted) Includes msw-storybook-addon in addons list.
ui/menu-website/package.json Bumps msw and msw-storybook-addon versions.
ui/menu-website/pnpm-workspace.yaml Removes the msw override now that addon v3 supports newer MSW internals.
ui/menu-website/pnpm-lock.yaml Lockfile updates reflecting the dependency bumps.
ui/menu-website/public/mockServiceWorker.js Updates the generated MSW service worker to 2.15.0.
AGENTS.md Updates documented Storybook/MSW guidance to the v3 handler registration pattern.
Files not reviewed (1)
  • ui/menu-website/pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ui/menu-website/tsconfig.storybook.json Outdated
@dgee2
dgee2 force-pushed the deps-msw-storybook-addon-major branch from 3e67f50 to 532765c Compare August 14, 2026 20:57
Bumps msw-storybook-addon 2.0.6 -> 3.0.0 and msw 2.12.14 -> 2.15.0
(these move together; msw-storybook-addon@2.0.6 is incompatible with
msw's newer worker internals, which is why Group 1 pinned msw down
via a pnpm override). Removes that override now that the addon
supports current msw.

msw-storybook-addon v3 removes `initialize()`/`mswLoader` in favor of
a `definePreview`-style `addons: [addonMsw(setupFn)]` call, and drops
`parameters.msw` support for CSF Next (this project's story format)
in favor of a `beforeEach({ msw }) { msw.use(handler) }` hook per
story. Updated .storybook/preview.ts and the three story files that
registered handlers accordingly.

This also surfaced and fixed two pre-existing, MSW-adjacent problems
that AGENTS.md had documented as "not currently reliable":
- MSW genuinely wasn't intercepting requests under
  `vitest --project=storybook` before (confirmed by probing — a
  stricter assertion against a previously "passing" story failed
  until the beforeEach migration). It works correctly now; updated
  AGENTS.md's component-testing guidance to match and removed the
  workaround comments in the affected story files.
- .storybook/msw-handlers.ts's recipe list fixtures used `name`
  instead of the real API's `title` field, which had gone unnoticed
  because MSW wasn't actually serving the response before.

Verified: lint, build, unit tests (57/57), storybook interaction
tests (78/78, now genuinely exercising mocked responses rather than
incidentally matching a fallback UI state), and a dev-server smoke
check. Playwright e2e (`pnpm run test:e2e`) fails, but on an
unrelated pre-existing stale scaffold assertion ("You did it!") that
doesn't match this app's actual content and is unmodified from main.

Co-authored-by: Claude <noreply@anthropic.com>
@dgee2
dgee2 force-pushed the deps-msw-storybook-addon-major branch from 532765c to ce06b5a Compare August 14, 2026 21:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@dgee2
dgee2 merged commit 2d14c70 into main Aug 14, 2026
14 checks passed
@dgee2
dgee2 deleted the deps-msw-storybook-addon-major branch August 14, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants